from tortoise import fields
from .base import BaseModel, TimestampMixin

class Goods(BaseModel, TimestampMixin):
    name = fields.CharField(max_length=200,null=True, description="商品名称")
    name_small = fields.CharField(max_length=200,null=True , description="副标题")
    tags = fields.JSONField(null=True, description="标签")
    brand_id = fields.IntField(default=0,null=True , max_length=10, description="品牌ID")
    cover = fields.CharField(max_length=255,null=True , description="封面")
    banners = fields.JSONField(null=True, description="轮播图")
    contents = fields.JSONField(null=True, description="详情页图")
    category_id = fields.IntField(default=0, max_length=10, description="类目ID")
    info_goods = fields.JSONField(null=True, description="产品信息")
    info_after = fields.JSONField(null=True, description="发货售后信息")
    sku = fields.JSONField(null=True, description="sku数据")
    is_level = fields.IntField(default=0, null=True ,max_length=10, description="是否升级礼包")
    is_level_type = fields.IntField(default=0,null=True , max_length=10, description="升级的等级")
    is_hot = fields.IntField(default=0, null=True ,max_length=10, description="是否预热商品")
    is_hot_date = fields.DatetimeField(null=True, description="开售时间")
    is_on = fields.IntField(default=0,null=True , max_length=10, description="商品定时上架")
    is_on_date = fields.DatetimeField(null=True, description="商品定时上架时间")
    is_off = fields.IntField(default=0,null=True , max_length=10, description="商品定时下架")
    is_off_date = fields.DatetimeField(null=True, description="商品定时下架时间")
    is_buy = fields.IntField(default=0,null=True , max_length=10, description="限购设置")
    is_buy_days = fields.IntField(default=0,null=True , max_length=10, description="多少天内限购")
    is_buy_nums = fields.IntField(default=0,null=True , max_length=10, description="多少件")
    is_low = fields.IntField(default=0, null=True ,max_length=10, description="最低起购设置")
    is_low_nums = fields.IntField(default=0,null=True , max_length=10, description="最低起购多少件")
    is_buy_level = fields.IntField(default=0,null=True , max_length=10, description="限制购买等级")
    is_buy_level_roles = fields.JSONField(null=True, description="限制购买等级,多选")
    is_read = fields.IntField(default=0,null=True , max_length=10, description="限制可见等级")
    is_read_roles = fields.JSONField(null=True, description="限制购买等级,多选")
    is_select_user = fields.IntField(default=0,null=True , max_length=10, description="指定用户可见可购买")
    is_select_user_users = fields.JSONField(null=True, description="限制购买等级,多选")
    is_share = fields.IntField(default=0,null=True , max_length=10, description="商品禁止分享")
    is_seven_day = fields.IntField(default=0,null=True , max_length=10, description="支持7天无理由")
    grow_id = fields.IntField(default=0,null=True , max_length=10, description="培育ID")
    order = fields.IntField(default=0,null=True , description="排序")
    desc = fields.CharField(max_length=500,null=True , description="备注")
    state = fields.BooleanField(default=True, description="0下架1上架中")
    express_id = fields.IntField(default=0,null=True , description="运费ID")
    contact_goods = fields.JSONField(null=True, description="关联商品")
    get_deposit = fields.IntField(default=0,null=True ,max_length=10, description="获得储值金")
    get_deposit_max = fields.IntField(default=0, null=True, max_length=10, description="最高获得储值金")
    get_integral = fields.IntField(default=0,null=True, max_length=10, description="获得积分")
    get_coupons = fields.IntField(default=0,null=True, max_length=10, description="获得优惠券id")
    type = fields.IntField(default=1, null=True, description="商品类型1项目2产品3储值4套餐卡")
    is_buckling = fields.IntField(default=0, null=True, description="是否需要划扣")
    get_level_integral = fields.IntField(default=0, null=True, max_length=10, description="获得成长积分")
    giver_integral = fields.IntField(default=0, null=True, max_length=10, description="赠送者获得积分")
    giver_level_integral = fields.IntField(default=0, null=True, max_length=10, description="赠送者获得成长积分")
    giver_coupons = fields.IntField(default=0, null=True, max_length=10, description="赠送者获得优惠券id")
    giver_deposit_max = fields.IntField(default=0, null=True, max_length=10, description="赠送者最高获得储值金")
    goods_id = fields.IntField(default=0, null=True, max_length=10, description="获得商品id")
    sku_id = fields.IntField(default=0, null=True, max_length=10, description="获得规格")
    giver_goods_id = fields.IntField(default=0, null=True, max_length=10, description="赠送者获得商品id")
    giver_sku_id = fields.IntField(default=0, null=True, max_length=10, description="赠送者获得规格")
    rebate = fields.IntField(default=0, null=True, max_length=10, description="提成发放方式 1购买2开卡")
    input_cps= fields.DecimalField(max_digits=10, decimal_places=2, description="录入人提成")
    operate_cps= fields.DecimalField(max_digits=10, decimal_places=2, description="技师提成")
    space_id = fields.JSONField(null=True, description="门店id")

    class Meta:
        table = "goods_list"

class GoodsCategory(BaseModel, TimestampMixin):
    name = fields.CharField(max_length=255, null=True, description="分类名称")
    desc = fields.CharField(max_length=500,null=True, description="备注")
    is_deleted = fields.BooleanField(default=False, description="软删除标记")
    order = fields.IntField(default=0, description="排序")
    parent_id = fields.IntField(default=0, max_length=10, description="父分类ID")
    attribute_ms_id = fields.JSONField(null=True, description="描述属性ID")
    attribute_gg_id = fields.JSONField(null=True, description="规格属性ID")
    cover = fields.CharField(max_length=255, null=True, description="分类封面")
    banner = fields.CharField(max_length=255, null=True, description="分类banner")

    class Meta:
        table = "goods_category"

class GoodsAttribute(BaseModel, TimestampMixin):
    name = fields.CharField(max_length=255, null=True, description="属性名称")
    type = fields.IntField(default=1, description="属性类型1规则属性2描述属性")
    tags = fields.JSONField(null=True, description="属性值")

    class Meta:
        table = "goods_attribute"


class GoodsBrand(BaseModel, TimestampMixin):
    name = fields.CharField(max_length=255, null=True, description="品牌名称")
    name_english = fields.CharField(max_length=255,null=True, description="品牌英文名称")
    cover = fields.CharField(max_length=255,null=True, description="封面")
    logo_image = fields.CharField(max_length=255,null=True, description="logo图")
    share_image = fields.CharField(max_length=255,null=True, description="分享图")
    desc = fields.CharField(max_length=255,null=True, description="介绍")
    topic_id = fields.IntField(default=0, description="关联专题页id")

    class Meta:
        table = "goods_brand"

class GoodsExpress(BaseModel, TimestampMixin):
    name = fields.CharField(max_length=255, null=True, description="模板名称")
    type = fields.IntField(default=1, description="计价方式1按件数2按重量")
    roles = fields.JSONField(null=True, description="区域运费规则")
    stop_roles = fields.JSONField(null=True, description="停发区域")

    class Meta:
        table = "goods_express"

class GoodsSku(BaseModel, TimestampMixin):
    goods_id = fields.IntField(default=0, description="商品id")
    sku_name = fields.CharField(max_length=255, null=True, description="sku名称")
    sku_kc = fields.IntField(default=1, description="库存")
    sku_price = fields.DecimalField(max_digits=10, decimal_places=2, description="原价")
    sku_cover = fields.JSONField(null=True, description="封面")
    sku_level = fields.JSONField(null=True, description="各个等级的价格")
    can_do = fields.IntField(default=1, description="可以使用的次数")
    include = fields.JSONField(null=True, description="包含套餐")

    class Meta:
        table = "goods_sku"

class GoodsGroup(BaseModel, TimestampMixin):
    name = fields.CharField(max_length=255, null=True, description="组合包名称")
    type = fields.IntField(default=1, description="类型1分次2总次3时段")
    times = fields.IntField(default=0, description="总次数/总天数")
    goods = fields.JSONField(null=True, description="组合包商品")
    goods_id = fields.IntField(default=0, description="商品的id")
    sku_id = fields.IntField(default=0, description="sku的id")
    type2 = fields.IntField(default=1, description="1必得2可选")

    class Meta:
        table = "goods_group"